<template>
  <div>
    <htz-image-upload
    
      :max="1"
      :headers="headers"
      v-model="ceshiData"
      @uploadSuccess="zidingyiSuccess"

      mediaType="video"
      :action="actions"

    >
    <!-- <view slot="addBtn" class="slot-btn" hover-class="slot-btn__hover" hover-stay-time="150">
		<u-icon name="plus" size="60" :color="$u.color['lightColor']"></u-icon>
	</view> -->
    </htz-image-upload>
  </div>
</template>

<script>
import htzImageUpload from "@/components/htz-image-upload/htz-image-upload.vue";
export default {
  model: {
    prop: "value",
    event: "upload"
  },
  components: {
    htzImageUpload
  },
  props: {
    //上传最大个数
    maxCount: {
      type: String,
      default: "1"
    },
    // 值
    value: {
      type: String,
      default: null
    }
  },
  data() {
    return {
      actions: this.fileUrl + "/api/common/upload",
      headers: {
        Authorization: "Bearer " + uni.getStorageSync("token")
      },
      ceshiData: []
    };
  },
  watch: {
    value: {
      handler(val, old) {
        if (old === null || old === undefined) {
          if (val) {
            this.$nextTick(() => {
              this.ceshiData = [this.fileUrl + val];
            });
          }
        }
      },
      deep: false,
      immediate: true
    }
  },
  methods: {
    zidingyiSuccess(res) {
      var _res = JSON.parse(res.data);
      if (_res.code == 200) {
        // return {
        //   success: true,
        //   url: this.fileUrl + _res.result
        // };
        this.$emit("upload", _res.fileName);
        this.ceshiData.push(this.fileUrl + _res.fileName);
      } else {
        return {
          success: false,
          url: ""
        };
      }
    },
    imgDelete(e) {
      this.$emit("upload", "");
    }
  }
};
</script>
<style lang="scss" scoped>
.slot-btn {
	width:150rpx;
	height:150rpx;
	display: flex;
	justify-content: center;
	align-items: center;
	background: rgb(255, 255, 255);
	// border-radius: 10rpx;
  border:4rpx solid #E3E3E3
}
/deep/  .htz-image-upload-Item-add {
  border:4rpx solid #E3E3E3;
  	background: rgb(255, 255, 255);
    	align-items: center;
      justify-content: center;
      	width:150rpx;
	height:150rpx;
	display: flex;
  color:#BEBEBE;
  font-size:80rpx
}
/deep/ .htz-image-upload-Item {
  border-radius: 0rpx
}

</style>